﻿@using Microsoft.Web.Helpers
@model Pro260Website.Models.VideoViewModel
 @if (!string.IsNullOrWhiteSpace(Model.YoutubeID) && !string.IsNullOrEmpty(Model.YoutubeID) && !Model.YoutubeID.Equals("http://www.youtube.com/v/"))
 {
     
       @Video.Flash(path: @Model.YoutubeID,
            width: "500",
            height: "400",
            menu: true)
 }

 @if (!string.IsNullOrEmpty(Model.VideoName) && !string.IsNullOrWhiteSpace(Model.VideoName))
 {
     bool fileExists = false;
     string fileExtension = string.Empty;

     DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/Content/Video"));
     FileInfo[] files = di.GetFiles();

     foreach (FileInfo file in files)
     {
         if (file.Name.Equals(Model.VideoName))
         {
             fileExists = true;
             break;
         }
     }

     if (fileExists)
     {
         for (int i = Model.VideoName.Length - 4; i < Model.VideoName.Length; i++)
         {
             fileExtension = "" + fileExtension + Model.VideoName[i];
         }

         string path = "~/Content/Video/" + Model.VideoName.Trim();

         if ((fileExtension.Equals(".wmv") || fileExtension.Equals(".avi")))
         {
             var browser = Request.Browser.Browser.ToLower();
             if (browser.Equals("ie"))
             {
                @Video.MediaPlayer(path: path,
                uiMode: "full",
                width: "500",
                height: "400",
                autoStart: false
                )
             }
             else
             {
                <embed type="application/x-ms/wmp" width="500" height="400" autostart="False"
                    URL=Content/Video/@Model.VideoName.Trim() enable="True" balance="0" currentPosition="0"
                    enableContextMenu="True" fullScreen="False" mute="False" playCount="1"
                    rate="1" stretchTofit="False" uiMode="3" />
             }
         }
         else if ((fileExtension.Equals(".swf") || fileExtension.Equals(".fla")))
         {
             var browser = Request.Browser.Browser.ToLower();
             if (browser.Equals("ie") || browser.Equals("chrome"))
             {
                @Video.MediaPlayer(path: path,
                    height: "450",
                    width: "350",
                    autoStart: false,
                    uiMode: "full")
             }
             else if (browser.Equals("firefox"))
             {
                @Video.Flash(path: path,
                    height: "450",
                    width: "350",
                    play: false,
                    loop: false,
                  menu: true)
                      
             }
         }
     }
 }